#! /bin/sh
# build velocity profiles with unif2
WIDTH=320
HEIGHT=300
WIDTHOFF1=0
WIDTHOFF2=330
WIDTHOFF3=0
WIDTHOFF4=330
HEIGHTOFF1=50
HEIGHTOFF2=50
HEIGHTOFF3=400
HEIGHTOFF4=400

HEIGHTOFF5=275
WIDTHOFF5=860

outfile=template
inprofile=inprofile
outprofile=outprofile
n1=100
n2=100
d1=10
d2=10

# use unif2 to output test datafile
# $outfile is an ascii file that shows the type of input unif2 requires
unif2  tfile=$outfile 

# create and display a velocity function
unif2 <$outfile n1=$n1 n2=$n2 > vintz.bin

# display original data
WOFF=$WIDTHOFF1
HOFF=$HEIGHTOFF1
ximage < vintz.bin  n1=$n1 n2=$n2 d1=$d1 d2=$d2 \
	title="original v(z) interval" \
	wbox=${WIDTH} hbox=${HEIGHT} xbox=${WOFF} ybox=${HOFF} &

# now apply velconv to the velocity profile, considered now as
# a v(z,x)  where z  is the fast dimension.

dt=.004
dz=10
ntout=250      #must specify enough output points to see full profile

# convert v(x,z) interval to v(x,t) interval
velconv intype=vintz outtype=vintt  nt=$ntout dt=$dt dz=$dz nz=$n1 nx=$n2 < vintz.bin > vintt.bin

# display
WOFF=$WIDTHOFF2
HOFF=$HEIGHTOFF2
ximage < vintt.bin  n1=$ntout n2=$n2 d1=$dt  \
	title="v(x,t) interval from v(z) interval" \
	wbox=${WIDTH} hbox=${HEIGHT} xbox=${WOFF} ybox=${HOFF} &


# make the output from the previous operation the input for the next operation

# convert v(x,t) interval to v(x,t) RMS
velconv intype=vintt outtype=vrmst nt=$ntout dt=$dt < vintt.bin > vrmst.bin

# display
WOFF=$WIDTHOFF3
HOFF=$HEIGHTOFF3
ximage < vrmst.bin  n1=$ntout n2=$n2 d1=$dt d2=$d2 \
	title="v(x,t) RMS from v(x,t) interval" \
	wbox=${WIDTH} hbox=${HEIGHT} xbox=${WOFF} ybox=${HOFF} &

# convert v(x,t) RMS into v(x,z)
velconv intype=vrmst outtype=vintz nt=$ntout dt=$dt < vintt.bin > vintzout.bin

# display
WOFF=$WIDTHOFF4
HOFF=$HEIGHTOFF4
ximage < vrmst.bin  n1=$ntout n2=$n2 d1=$dt d2=$d2 \
	title="v(z) interval from v(x,t) RMS (compare with 1st plot)" \
	wbox=${WIDTH} hbox=${HEIGHT} xbox=${WOFF} ybox=${HOFF} &


exit 0
